from django.db import models
from django.utils import timezone
import datetime
from . import enums
# Create your models here.
class Team(models.Model):
    def __str__(self):
        return self.team_name
    team_number = models.CharField(max_length=20,unique=True)
    team_name = models.CharField(max_length=80)
    team_type = models.CharField(max_length=1, choices=enums.TeamType)

class Contract(models.Model):
    def __str__(self):
        return self.contract_number
    contract_number = models.CharField(max_length=40,unique=True)
    design_type = models.CharField(max_length=20,choices=enums.DesignType)
    team_list = models.ManyToManyField(Team)

class ContractDetail(models.Model):
    def __str__(self):
        return self.contract.contract_number
    contract = models.ForeignKey(Contract, on_delete=models.CASCADE,related_name='details')
    contract_type = models.CharField(max_length = 1,choices=enums.ContractType)
    building_type = models.CharField(max_length = 1,choices=enums.BuildingType)
    area = models.DecimalField(max_digits=9, decimal_places=2,default=0)
    unit_price = models.DecimalField(max_digits=9, decimal_places=2,default=0)


class Payment(models.Model):
    def __str__(self):
        return self.amount
    contract = models.ForeignKey(Contract, on_delete=models.CASCADE)
    amount = models.DecimalField(max_digits=19, decimal_places=2)
    payment_date = models.DateField()
